home *** CD-ROM | disk | FTP | other *** search
/ ftp.mactech.com 2010 / ftp.mactech.com.tar / ftp.mactech.com / thinkref / archive / THINKPascalUH2.1.sea / THINKPas Univ Hdr 2.1 / Interfaces / ObjIntf.p < prev    next >
Text File  |  1995-09-13  |  2KB  |  73 lines

  1. { Converted with MPW2TPas Tuesday, September 12, 1995 7:59:53 PM }
  2. {}
  3. {    File:        ObjIntf.p}
  4. {}
  5. {    Copyright:    © 1983-1993 by Apple Computer, Inc.}
  6. {                All rights reserved.}
  7. {}
  8. {    Version:    System 7.1 for ETO #11}
  9. {    Created:    Tuesday, March 30, 1993 18:00}
  10. {}
  11. {}
  12.  
  13. unit ObjIntf;
  14. interface
  15.  
  16.  
  17. {$IFC UNDEFINED UsingObjIntf}
  18. {$SETC UsingObjIntf := 1}
  19.  
  20.  
  21.     type
  22.         TObject = object
  23.                 function ShallowClone: TObject;
  24.             {Lowest level method for copying an object; should not be overridden}
  25. {                except in very unusual cases.  Simply calls HandToHand to copy}
  26. {                the object data.}
  27.                 function Clone: TObject;
  28.             {Defaults to calling ShallowClone; can be overridden to copy objects}
  29. {                refered to by fields.}
  30.                 procedure ShallowFree;
  31.             {Lowest level method for freeing an object; should not be overridden}
  32. {                except in very unusual cases.  Simply calls DisposHandle to}
  33. {                free the object data.}
  34.                 procedure Free;
  35.             {Defaults to calling ShallowFree; can be overridden to free objects }
  36. {                refered to by fields.}
  37.             end;
  38.  
  39.  
  40. {$ENDC}
  41.  { UsingObjIntf }
  42.  
  43. implementation
  44.  
  45.     function TObject.ShallowClone;
  46.         var
  47.             result: Handle;
  48.     begin
  49.         result := Handle(SELF);
  50.         if HandToHand(result) <> noErr then
  51.             begin
  52.                   { report some sort of error? }
  53.                 result := nil
  54.             end;
  55.         ShallowClone := TObject(result);
  56.     end;
  57.  
  58.     function TObject.Clone;
  59.     begin
  60.         Clone := SELF.ShallowClone;
  61.     end;
  62.  
  63.     procedure TObject.ShallowFree;
  64.     begin
  65.         DisposHandle(Handle(SELF));
  66.     end;
  67.  
  68.     procedure TObject.Free;
  69.     begin
  70.         SELF.ShallowFree;
  71.     end;
  72.  
  73. end.